home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-25 | 2.0 KB | 91 lines | [TEXT/CWIE] |
- // ==================================================
- // UErrorMessage.cp
- // Copyright (C) 1994-1997 Mizutori Tetsuya
- // March 9, 1994; July 4, 1996; February 3, 1997.
- // ==================================================
- // All documents are pretty-printed in 10-point Geneva font.
-
- #include <Resources.h>
- #include <Memory.h>
- #include <TextUtils.h>
- #include <Dialogs.h>
- #include <SegLoad.h>
- #include <Processes.h>
- #include <Notification.h>
- #include <Errors.h>
-
- #include <UDesktop.h>
-
- #include "UErrorMessage.h"
-
-
- const ResType kErrorMessage_ResType = 'ErrM';
-
- const ResIDT ALRT_ErrorBox = 9000;
-
-
- // --------------------------------------------------
- // • NofityIfOSErr
- // --------------------------------------------------
-
- void
- UErrorMessage::NofityIfOSErr(
- const OSErr inErr,
- const Boolean inBeFatal )
- {
- NofityIfOSErr( inErr, "\p", inBeFatal );
- }
-
-
- // --------------------------------------------------
- // • NofityIfOSErr
- // --------------------------------------------------
-
- void
- UErrorMessage::NofityIfOSErr(
- const OSErr inErr,
- const Str255 inText,
- const Boolean inBeFatal )
- {
-
- if ( inErr == noErr ) return;
-
- Str31 theErrNumber;
- Str255 theResName;
- Str255 theErrMessage;
- Handle theResourceH;
-
- theResourceH = ::GetResource( kErrorMessage_ResType, (short) inErr );
- if ( theResourceH != nil ) {
- short theID;
- ResType theType;
- ::GetResInfo( theResourceH, &theID, &theType, theResName );
- theErrMessage[0] = ::GetHandleSize( theResourceH );
- ::BlockMoveData( (Ptr) *theResourceH, &theErrMessage[0], theErrMessage[0] );
- ::ReleaseResource( theResourceH );
- } else {
- theResName[0] = 0;
- theErrMessage[0] = 0;
- }
-
- ::NumToString( inErr, theErrNumber );
-
- ::ParamText( theResName, theErrNumber, theErrMessage, inText );
-
- // Deactivate the desktop.
- UDesktop::Deactivate();
-
- if ( inBeFatal ) {
- ::StopAlert( ALRT_ErrorBox, nil );
- ::ExitToShell();
- } else {
- ::NoteAlert( ALRT_ErrorBox, nil );
- }
-
- // Activate the desktop.
- UDesktop::Activate();
- }
-
-
- // end of program
-